$(document).ready(function () {
    setWXConfig(preUrl + "PaymentResult.html");

    //document.getElementById('allDiv').style.display = 'block';
    document.getElementById("bottom").style.marginTop = ((document.body.scrollHeight - document.body.clientHeight)-30) + "px";
    document.getElementById("bottom").style.display = "block";
    var paras = getUrlParameters();
    $.ajax({
        url: preUrl + "order/detail/" + paras.accountNo + "/" + paras.id,
        type: "get",
        dataType: "json",
        success: function (data) {
            if (typeof(data) == "undefined") {
                alert("访问服务器失败，请稍后重试");
            } else {
                if (data.resCode == "0000") {
                    if ("10" == data.resModel.payStatus) {
                        $("#title").text("缴费成功！");
                    } else if ("20" == data.resModel.payStatus) {
                        $("#title").text("缴费失败！");
                        $("#titleImg").attr("src", $("#titleImg").attr("src").replace("duigou2", "chahao"));
                    } else if ("30" == data.resModel.payStatus) {
                        $("#title").text("退款成功！");
                    } else if ("31" == data.resModel.payStatus) {
                        $("#title").text("退款失败！");
                        $("#titleImg").attr("src", $("#titleImg").attr("src").replace("duigou2", "chahao"));
                    } else {
                        $("#title").text("未支付！");
                        $("#titleImg").attr("src", $("#titleImg").attr("src").replace("duigou2", "chahao"));
                    }
                    $('#payFee').text((data.resModel.totalFee / 100).toFixed(2) );

                    if (data.resModel.accountNo) {
                        $("#accountNo").text(data.resModel.accountNo);
                    }
                    if (data.resModel.serialNo) {
                        $("#serialNo").text(data.resModel.serialNo);
                    }
                    if (data.resModel.payTimes) {
                        $("#payTimes").text(data.resModel.payTimes);
                    }
                    if (data.resModel.attach) {
                        $("#attach").text(data.resModel.attach);
                    }
                    if (data.resModel.attach) {
                        $("#userAddr").text(data.resModel.userAddr);
                    }
                    if (data.resModel.attach) {
                        $("#userName").text(data.resModel.userName);
                    }
                } else {
                    if (data.resCode == '1001') {
                        refreshPages();
                    } else if (data.resCode == '2000') {
                        $("#allDiv").html('');
                        document.getElementById('allDiv').style.display = 'block';
                        var content = '<div style="background:#f7f7f7"><div '
                            + 'style="padding-top:50px;text-align:center;font-size:14px;color:#808080;'
                            + 'padding-bottom:30px;" >' + data.errorinfo
                            + '</div></div>';
                        $("#allDiv").append(content);
                    } else {
                        alert("访问服务器失败，请稍后重试");
                    }
                }
                document.getElementById('allDiv').style.display = 'block';
            }
        },
        error: function (data) {
            alert("访问服务器失败，请稍后重试");
        }
    });

});
